package com.example.qingyiapp.ui.activity.fragment.fragment_FindUI;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.qingyiapp.R;
import com.example.qingyiapp.ui.activity.fragment.fragment_FindUI.adapter.FindfragmentAdapter;
import com.example.qingyiapp.ui.activity.fragment.fragment_FindUI.childfragment.Choiceness;
import com.example.qingyiapp.ui.activity.fragment.fragment_FindUI.childfragment.Recommend;
import com.example.qingyiapp.ui.activity.fragment.fragment_FindUI.childfragment.Square;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * A simple {@link Fragment} subclass.
 */
public class Fragment_FindUI extends Fragment {


    @BindView(R.id.find_tablayout)
    TabLayout findTablayout;
    @BindView(R.id.find_viewPager)
    ViewPager findViewPager;
    Unbinder unbinder;

    public Fragment_FindUI() {
        // Required empty public constructor
    }



    ArrayList<String> titles;
    ArrayList<Fragment> fragments;
    FindfragmentAdapter findfragmentAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.fragment_fragment__find_ui, container, false);
        unbinder = ButterKnife.bind(this, inflate);

        titles = new ArrayList<>();
        fragments = new ArrayList<>();
        titles.add("推荐热点");
        titles.add("驿友精选");
        titles.add("问答广场");

        fragments.add(new Recommend());
        fragments.add(new Choiceness());
        fragments.add(new Square());
        findfragmentAdapter = new FindfragmentAdapter(getChildFragmentManager(), fragments, titles);
        findViewPager.setAdapter(findfragmentAdapter);
        findTablayout.setupWithViewPager(findViewPager);





        return inflate;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
